-
-
Notifications
You must be signed in to change notification settings - Fork 11.5k
[Model Runner V2] Change bookkeeping logic in preparation for spec decoding #29194
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
WoosukKwon
wants to merge
185
commits into
main
Choose a base branch
from
woosuk/tmp-v2
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+266
−143
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Signed-off-by: Woosuk Kwon <[email protected]>
Signed-off-by: Woosuk Kwon <[email protected]>
Signed-off-by: Woosuk Kwon <[email protected]>
Signed-off-by: Woosuk Kwon <[email protected]>
Signed-off-by: Woosuk Kwon <[email protected]>
Signed-off-by: Woosuk Kwon <[email protected]>
Signed-off-by: Woosuk Kwon <[email protected]>
Signed-off-by: Woosuk Kwon <[email protected]>
Signed-off-by: Woosuk Kwon <[email protected]>
Signed-off-by: Woosuk Kwon <[email protected]>
Signed-off-by: Woosuk Kwon <[email protected]>
Signed-off-by: Woosuk Kwon <[email protected]>
Signed-off-by: Woosuk Kwon <[email protected]>
Signed-off-by: Woosuk Kwon <[email protected]>
Signed-off-by: Woosuk Kwon <[email protected]>
Signed-off-by: Woosuk Kwon <[email protected]>
Signed-off-by: Woosuk Kwon <[email protected]>
Signed-off-by: Woosuk Kwon <[email protected]>
Signed-off-by: Woosuk Kwon <[email protected]>
Signed-off-by: Woosuk Kwon <[email protected]>
Signed-off-by: Woosuk Kwon <[email protected]>
Signed-off-by: Woosuk Kwon <[email protected]>
Signed-off-by: Woosuk Kwon <[email protected]>
Signed-off-by: Woosuk Kwon <[email protected]>
Signed-off-by: Woosuk Kwon <[email protected]>
Signed-off-by: Woosuk Kwon <[email protected]>
Signed-off-by: Woosuk Kwon <[email protected]>
Signed-off-by: Woosuk Kwon <[email protected]>
Signed-off-by: Woosuk Kwon <[email protected]>
Signed-off-by: Woosuk Kwon <[email protected]>
Signed-off-by: Woosuk Kwon <[email protected]>
Signed-off-by: Woosuk Kwon <[email protected]>
Signed-off-by: Woosuk Kwon <[email protected]>
Signed-off-by: Woosuk Kwon <[email protected]>
WoosukKwon
commented
Nov 21, 2025
Comment on lines
+473
to
+480
| # Get num_computed_tokens. | ||
| # HACK(woosuk): Here, we use num_computed_tokens on GPU instead of | ||
| # num_computed_tokens_cpu. This works for most cases. | ||
| num_computed_tokens = self.req_states.num_computed_tokens[idx_mapping] | ||
| # HACK(woosuk): Only GPU has the exact seq_lens because at this point | ||
| # CPU does not know how many draft tokens are accepted/rejected in the | ||
| # previous step. Therefore, we use max_model_len to be safe. | ||
| seq_lens_np = np.full(num_reqs, self.max_model_len, dtype=np.int32) |
Collaborator
Author
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@LucasWilkinson This is my current hack, which is totally undesirable. I plan to use a tighter upper bound for seq_lens_np, but I'd like to keep it if the refactoring may happen in the near future.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR updates the input-preparation and bookkeeping logic for the V2 model runner. The primary goal is to shift as much work as possible onto the GPU, laying the groundwork for async scheduling + speculative decoding.
Key changes
num_computed_tokensis now GPU-only.The CPU no longer tracks this value. Instead, it maintains
num_computed_prefill_tokens, which is used to track the progress of chunked prefills.Prefill and decode input preparation are now decoupled.
num_computed_prefill_tokens) are read from NumPy arrays.last_sampled_tokensandnum_computed_tokensdirectly from the GPU.Preparation for speculative decoding.
We now maintain
num_sampled_tokensas GPU tensors for upcoming spec-decode support (where the number of accepted tokens are dynamic).